package huoye.shops.huoye.operation.presenter;

import java.util.List;

import huoye.shops.base.BasePresenter;
import huoye.shops.base.MineBaseJsonRequestCallback;
import huoye.shops.huoye.mine.model.PowerList;
import huoye.shops.huoye.operation.model.GuestsDetailData;
import huoye.shops.huoye.operation.networt.OperationService;
import huoye.shops.huoye.operation.view.IGuestsSetView;
import huoye.shops.huoye.operation.view.IOperationView;


/**
 * Created by uesr on 2017/7/19.
 */

public class OperationPresenter extends BasePresenter<IOperationView> {

    OperationService mService;


    //获取特权用户详情
    public void getPrivilegedGuestDetail(final String shopSpeGuestId){
        mService.getPrivilegedGuestDetail(shopSpeGuestId ,new MineBaseJsonRequestCallback<GuestsDetailData>(GuestsDetailData.class) {

            @Override
            public void onSuccess(GuestsDetailData guestsDetailData) {
                super.onSuccess(guestsDetailData);
            }

            //网络请求失败
            @Override
            public void onFailure(String msg, String code, Throwable e) {
                super.onFailure(msg, code, e);
                view.makeToast(msg);
            }

            //加载结束
            @Override
            public void onNetworkFail() {
                super.onNetworkFail();
                view.onNetworkFail();
            }

            //加载中
            @Override
            public void onFinish() {
                super.onFinish();
                view.hideProcessingIndicator();
            }
        });
    }


    //获取当前用户的权限列表
    public void getUserPowers(){
        mService.getUserPowers(new MineBaseJsonRequestCallback<PowerList>(PowerList.class) {

            @Override
            public void onSuccess(List<PowerList> list) {
                super.onSuccess(list);
                view.setPowerList(list);

            }

            //网络请求失败
            @Override
            public void onFailure(String msg, String code, Throwable e) {
                super.onFailure(msg, code, e);
                view.makeToast(msg);
            }

            //加载结束
            @Override
            public void onNetworkFail() {
                super.onNetworkFail();
                view.onNetworkFail();
            }

            //加载中
            @Override
            public void onFinish() {
                super.onFinish();
                view.hideProcessingIndicator();
            }
        });
    }



    @Override
    public void onStart() {
        mService = new OperationService();
    }
}
